﻿namespace HRM.CORE.Process
{
    using DevExpress.Utils;
    using DevExpress.XtraEditors;
    using DevExpress.XtraEditors.Controls;
    using DevExpress.XtraGrid.Columns;
    using DevExpress.XtraGrid.Views.Grid;
    using APP.HELPER;
    using HRM.CORE;
    
    using System; using Extra.ERP;
    using System.ComponentModel;
    using System.Drawing;
    using System.Runtime.CompilerServices;
    using System.Windows.Forms; using Common;
    using Common;
    using APP.HELPER.Utils.Language;
    using Security.ERP;

    public class xucAccidentAdd : Common.xucBaseAddH
    {
        private GridColumn colEmployeeCode;
        private GridColumn colFirstName;
        private GridColumn colLastName;
        private IContainer components = null;
        private DateEdit dtDateOccured;
        private GridLookUpEdit glkEmployeeCode;
        private GridView gridLookUpEdit1View;
        private GroupControl grInformation;
        private LabelControl labelControl1;
        private LabelControl lcAccidentName;
        private LabelControl lcAllowance;
        private LabelControl lcDamage;
        private LabelControl lcDateOccured;
        private LabelControl lcDescription;
        private LabelControl lcInjury;
        private LabelControl lcLocation;
        private LabelControl lcNote;
        private LabelControl lcReason;
        private Guid m_AccidentID = Guid.Empty;
        private string m_EmployeeCode = "";
        private TextEdit txtAccidentName;
        private TextEdit txtAllowance;
        private MemoEdit txtDamage;
        private MemoEdit txtDescription;
        private TextEdit txtEmployeeName;
        private TextEdit txtInjury;
        private TextEdit txtLocation;
        private MemoEdit txtNote;
        private TextEdit txtReason;

        public event SuccessEventHander Success;

        public xucAccidentAdd()
        {
            this.InitializeComponent();
            this.InitData();
            this.InitComponent();
        }

        protected override void Add()
        {
            base.Add();
            HRM_PROCESS_ACCIDENT hrm_process_accident = new HRM_PROCESS_ACCIDENT();
        }

        public void Clear()
        {
            this.txtAccidentName.Text = "";
            this.txtReason.Text = "";
            this.txtLocation.Text = "";
            this.txtDescription.Text = "";
            this.txtDamage.Text = "";
            this.txtInjury.Text = "";
            this.txtAllowance.Text = "";
            this.txtNote.Text = "";
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void glkEmployeeCode_EditValueChanged(object sender, EventArgs e)
        {
            this.m_EmployeeCode = this.glkEmployeeCode.EditValue.ToString();
            this.LoadEmployeeInformation();
        }

        protected override void Init()
        {
        }

        private void InitComponent()
        {
            this.dtDateOccured.DateTime = DateTime.Now;
        }

        private void InitData()
        {
            new HRM_EMPLOYEE().AddGridLookupEdit(this.glkEmployeeCode);
        }

        private void InitializeComponent()
        {
            ComponentResourceManager manager = new ComponentResourceManager(typeof(xucAccidentAdd));
            this.grInformation = new GroupControl();
            this.labelControl1 = new LabelControl();
            this.txtEmployeeName = new TextEdit();
            this.glkEmployeeCode = new GridLookUpEdit();
            this.gridLookUpEdit1View = new GridView();
            this.colEmployeeCode = new GridColumn();
            this.colFirstName = new GridColumn();
            this.colLastName = new GridColumn();
            this.lcNote = new LabelControl();
            this.txtNote = new MemoEdit();
            this.lcAllowance = new LabelControl();
            this.txtAllowance = new TextEdit();
            this.lcInjury = new LabelControl();
            this.txtInjury = new TextEdit();
            this.lcDamage = new LabelControl();
            this.txtDamage = new MemoEdit();
            this.lcDescription = new LabelControl();
            this.lcLocation = new LabelControl();
            this.txtLocation = new TextEdit();
            this.lcAccidentName = new LabelControl();
            this.txtAccidentName = new TextEdit();
            this.lcReason = new LabelControl();
            this.dtDateOccured = new DateEdit();
            this.txtReason = new TextEdit();
            this.lcDateOccured = new LabelControl();
            this.txtDescription = new MemoEdit();
            ((ISupportInitialize) base.Err).BeginInit();
            base.imageCollection2.BeginInit();
            this.grInformation.BeginInit();
            this.grInformation.SuspendLayout();
            this.txtEmployeeName.Properties.BeginInit();
            this.glkEmployeeCode.Properties.BeginInit();
            this.gridLookUpEdit1View.BeginInit();
            this.txtNote.Properties.BeginInit();
            this.txtAllowance.Properties.BeginInit();
            this.txtInjury.Properties.BeginInit();
            this.txtDamage.Properties.BeginInit();
            this.txtLocation.Properties.BeginInit();
            this.txtAccidentName.Properties.BeginInit();
            this.dtDateOccured.Properties.VistaTimeProperties.BeginInit();
            this.dtDateOccured.Properties.BeginInit();
            this.txtReason.Properties.BeginInit();
            this.txtDescription.Properties.BeginInit();
            base.SuspendLayout();
            base.btnSave.Location = new Point(0x10f, 0x157);
            base.btnSave.TabIndex = 1;
            base.btnCancel.Location = new Point(470, 0x157);
            base.btnCancel.TabIndex = 3;
            base.btnSaveNew.Location = new Point(0x171, 0x157);
            base.btnSaveNew.TabIndex = 2;
            base.imageCollection2.ImageStream = (ImageCollectionStreamer) manager.GetObject("imageCollection2.ImageStream");
            this.grInformation.Controls.Add(this.labelControl1);
            this.grInformation.Controls.Add(this.txtEmployeeName);
            this.grInformation.Controls.Add(this.glkEmployeeCode);
            this.grInformation.Controls.Add(this.lcNote);
            this.grInformation.Controls.Add(this.txtNote);
            this.grInformation.Controls.Add(this.lcAllowance);
            this.grInformation.Controls.Add(this.txtAllowance);
            this.grInformation.Controls.Add(this.lcInjury);
            this.grInformation.Controls.Add(this.txtInjury);
            this.grInformation.Controls.Add(this.lcDamage);
            this.grInformation.Controls.Add(this.txtDamage);
            this.grInformation.Controls.Add(this.lcDescription);
            this.grInformation.Controls.Add(this.lcLocation);
            this.grInformation.Controls.Add(this.txtLocation);
            this.grInformation.Controls.Add(this.lcAccidentName);
            this.grInformation.Controls.Add(this.txtAccidentName);
            this.grInformation.Controls.Add(this.lcReason);
            this.grInformation.Controls.Add(this.dtDateOccured);
            this.grInformation.Controls.Add(this.txtReason);
            this.grInformation.Controls.Add(this.lcDateOccured);
            this.grInformation.Controls.Add(this.txtDescription);
            this.grInformation.Dock = DockStyle.Top;
            this.grInformation.Location = new Point(0, 0);
            this.grInformation.Name = "grInformation";
            this.grInformation.Size = new Size(0x23e, 0x14e);
            this.grInformation.TabIndex = 0;
            this.grInformation.Text = "Th\x00f4ng Tin Tai Nạn";
            this.labelControl1.AllowHtmlString = true;
            this.labelControl1.Location = new Point(9, 0x20);
            this.labelControl1.Name = "labelControl1";
            this.labelControl1.Size = new Size(0x3e, 14);
            this.labelControl1.TabIndex = 0;
            this.labelControl1.Text = "Chọn NV <color=red>(*)</color>:";
            this.txtEmployeeName.Enabled = false;
            this.txtEmployeeName.Location = new Point(0xe2, 30);
            this.txtEmployeeName.Name = "txtEmployeeName";
            this.txtEmployeeName.Size = new Size(0x153, 20);
            this.txtEmployeeName.TabIndex = 2;
            this.glkEmployeeCode.Location = new Point(0x4e, 30);
            this.glkEmployeeCode.Name = "glkEmployeeCode";
            this.glkEmployeeCode.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.glkEmployeeCode.Properties.NullText = "[Chọn nh\x00e2n vi\x00ean]";
            this.glkEmployeeCode.Properties.View = this.gridLookUpEdit1View;
            this.glkEmployeeCode.Size = new Size(0x8e, 20);
            this.glkEmployeeCode.TabIndex = 1;
            this.glkEmployeeCode.EditValueChanged += new EventHandler(this.glkEmployeeCode_EditValueChanged);
            this.gridLookUpEdit1View.Columns.AddRange(new GridColumn[] { this.colEmployeeCode, this.colFirstName, this.colLastName });
            this.gridLookUpEdit1View.FocusRectStyle = DrawFocusRectStyle.RowFocus;
            this.gridLookUpEdit1View.Name = "gridLookUpEdit1View";
            this.gridLookUpEdit1View.OptionsSelection.EnableAppearanceFocusedCell = false;
            this.gridLookUpEdit1View.OptionsView.ShowAutoFilterRow = true;
            this.gridLookUpEdit1View.OptionsView.ShowGroupPanel = false;
            this.colEmployeeCode.Caption = "M\x00e3 nh\x00e2n vi\x00ean";
            this.colEmployeeCode.FieldName = "EmployeeCode";
            this.colEmployeeCode.Name = "colEmployeeCode";
            this.colEmployeeCode.Visible = true;
            this.colEmployeeCode.VisibleIndex = 0;
            this.colFirstName.Caption = "Họ l\x00f3t";
            this.colFirstName.FieldName = "FirstName";
            this.colFirstName.Name = "colFirstName";
            this.colFirstName.Visible = true;
            this.colFirstName.VisibleIndex = 1;
            this.colLastName.Caption = "T\x00ean";
            this.colLastName.FieldName = "LastName";
            this.colLastName.Name = "colLastName";
            this.colLastName.Visible = true;
            this.colLastName.VisibleIndex = 2;
            this.lcNote.Location = new Point(9, 0x11e);
            this.lcNote.Name = "lcNote";
            this.lcNote.Size = new Size(0x27, 13);
            this.lcNote.TabIndex = 0x13;
            this.lcNote.Text = "Ghi ch\x00fa:";
            this.txtNote.Location = new Point(0x4e, 0x11c);
            this.txtNote.Name = "txtNote";
            this.txtNote.Properties.Appearance.Options.UseTextOptions = true;
            this.txtNote.Properties.Appearance.TextOptions.VAlignment = VertAlignment.Top;
            this.txtNote.Properties.Appearance.TextOptions.WordWrap = WordWrap.Wrap;
            this.txtNote.Size = new Size(0x1e7, 0x29);
            this.txtNote.TabIndex = 20;
            this.lcAllowance.Location = new Point(9, 0x105);
            this.lcAllowance.Name = "lcAllowance";
            this.lcAllowance.Size = new Size(0x38, 13);
            this.lcAllowance.TabIndex = 0x11;
            this.lcAllowance.Text = "Bồi thường:";
            this.txtAllowance.Location = new Point(0x4e, 0x102);
            this.txtAllowance.Name = "txtAllowance";
            this.txtAllowance.Properties.Appearance.Options.UseTextOptions = true;
            this.txtAllowance.Properties.Appearance.TextOptions.VAlignment = VertAlignment.Top;
            this.txtAllowance.Properties.Appearance.TextOptions.WordWrap = WordWrap.Wrap;
            this.txtAllowance.Properties.AutoHeight = false;
            this.txtAllowance.Size = new Size(0x1e7, 20);
            this.txtAllowance.TabIndex = 0x12;
            this.lcInjury.Location = new Point(9, 0xeb);
            this.lcInjury.Name = "lcInjury";
            this.lcInjury.Size = new Size(0x3a, 13);
            this.lcInjury.TabIndex = 15;
            this.lcInjury.Text = "Thương tật:";
            this.txtInjury.Location = new Point(0x4e, 0xe8);
            this.txtInjury.Name = "txtInjury";
            this.txtInjury.Properties.Appearance.Options.UseTextOptions = true;
            this.txtInjury.Properties.Appearance.TextOptions.VAlignment = VertAlignment.Top;
            this.txtInjury.Properties.Appearance.TextOptions.WordWrap = WordWrap.Wrap;
            this.txtInjury.Properties.AutoHeight = false;
            this.txtInjury.Size = new Size(0x1e7, 20);
            this.txtInjury.TabIndex = 0x10;
            this.lcDamage.Location = new Point(9, 0xbb);
            this.lcDamage.Name = "lcDamage";
            this.lcDamage.Size = new Size(0x2d, 13);
            this.lcDamage.TabIndex = 13;
            this.lcDamage.Text = "Thiệt hại:";
            this.txtDamage.Location = new Point(0x4e, 0xb9);
            this.txtDamage.Name = "txtDamage";
            this.txtDamage.Properties.Appearance.Options.UseTextOptions = true;
            this.txtDamage.Properties.Appearance.TextOptions.VAlignment = VertAlignment.Top;
            this.txtDamage.Properties.Appearance.TextOptions.WordWrap = WordWrap.Wrap;
            this.txtDamage.Size = new Size(0x1e7, 0x29);
            this.txtDamage.TabIndex = 14;
            this.lcDescription.Location = new Point(9, 0x8b);
            this.lcDescription.Name = "lcDescription";
            this.lcDescription.Size = new Size(0x1f, 13);
            this.lcDescription.TabIndex = 11;
            this.lcDescription.Text = "M\x00f4 tả:";
            this.lcDescription.Click += new EventHandler(this.labelControl7_Click);
            this.lcLocation.Location = new Point(9, 0x71);
            this.lcLocation.Name = "lcLocation";
            this.lcLocation.Size = new Size(0x2d, 13);
            this.lcLocation.TabIndex = 9;
            this.lcLocation.Text = "Địa điểm:";
            this.txtLocation.Location = new Point(0x4e, 110);
            this.txtLocation.Name = "txtLocation";
            this.txtLocation.Properties.Appearance.Options.UseTextOptions = true;
            this.txtLocation.Properties.Appearance.TextOptions.VAlignment = VertAlignment.Top;
            this.txtLocation.Properties.Appearance.TextOptions.WordWrap = WordWrap.Wrap;
            this.txtLocation.Properties.AutoHeight = false;
            this.txtLocation.Size = new Size(0x1e7, 20);
            this.txtLocation.TabIndex = 10;
            this.lcAccidentName.Location = new Point(9, 0x3b);
            this.lcAccidentName.Name = "lcAccidentName";
            this.lcAccidentName.Size = new Size(0x26, 13);
            this.lcAccidentName.TabIndex = 3;
            this.lcAccidentName.Text = "Về việc:";
            this.txtAccidentName.Location = new Point(0x4e, 0x39);
            this.txtAccidentName.Name = "txtAccidentName";
            this.txtAccidentName.Properties.Appearance.Options.UseTextOptions = true;
            this.txtAccidentName.Properties.Appearance.TextOptions.VAlignment = VertAlignment.Top;
            this.txtAccidentName.Properties.Appearance.TextOptions.WordWrap = WordWrap.Wrap;
            this.txtAccidentName.Properties.AutoHeight = false;
            this.txtAccidentName.Size = new Size(0x142, 20);
            this.txtAccidentName.TabIndex = 4;
            this.lcReason.Location = new Point(9, 0x56);
            this.lcReason.Name = "lcReason";
            this.lcReason.Size = new Size(30, 13);
            this.lcReason.TabIndex = 7;
            this.lcReason.Text = "L\x00fd do:";
            this.dtDateOccured.EditValue = null;
            this.dtDateOccured.Location = new Point(0x1db, 0x39);
            this.dtDateOccured.Name = "dtDateOccured";
            this.dtDateOccured.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.dtDateOccured.Properties.VistaTimeProperties.Buttons.AddRange(new EditorButton[] { new EditorButton() });
            this.dtDateOccured.Size = new Size(90, 20);
            this.dtDateOccured.TabIndex = 6;
            this.txtReason.Location = new Point(0x4e, 0x53);
            this.txtReason.Name = "txtReason";
            this.txtReason.Properties.Appearance.Options.UseTextOptions = true;
            this.txtReason.Properties.Appearance.TextOptions.VAlignment = VertAlignment.Top;
            this.txtReason.Properties.Appearance.TextOptions.WordWrap = WordWrap.Wrap;
            this.txtReason.Properties.AutoHeight = false;
            this.txtReason.Size = new Size(0x1e7, 20);
            this.txtReason.TabIndex = 8;
            this.lcDateOccured.Location = new Point(0x196, 60);
            this.lcDateOccured.Name = "lcDateOccured";
            this.lcDateOccured.Size = new Size(0x3f, 13);
            this.lcDateOccured.TabIndex = 5;
            this.lcDateOccured.Text = "Ng\x00e0y xảy ra:";
            this.txtDescription.Location = new Point(0x4e, 0x89);
            this.txtDescription.Name = "txtDescription";
            this.txtDescription.Properties.Appearance.Options.UseTextOptions = true;
            this.txtDescription.Properties.Appearance.TextOptions.VAlignment = VertAlignment.Top;
            this.txtDescription.Properties.Appearance.TextOptions.WordWrap = WordWrap.Wrap;
            this.txtDescription.Size = new Size(0x1e7, 0x29);
            this.txtDescription.TabIndex = 12;
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.Controls.Add(this.grInformation);
            base.Name = "xucAccidentAdd";
            base.Size = new Size(0x23e, 0x179);
            base.Controls.SetChildIndex(base.btnCancel, 0);
            base.Controls.SetChildIndex(base.btnSave, 0);
            base.Controls.SetChildIndex(base.btnSaveNew, 0);
            base.Controls.SetChildIndex(this.grInformation, 0);
            ((ISupportInitialize) base.Err).EndInit();
            base.imageCollection2.EndInit();
            this.grInformation.EndInit();
            this.grInformation.ResumeLayout(false);
            this.grInformation.PerformLayout();
            this.txtEmployeeName.Properties.EndInit();
            this.glkEmployeeCode.Properties.EndInit();
            this.gridLookUpEdit1View.EndInit();
            this.txtNote.Properties.EndInit();
            this.txtAllowance.Properties.EndInit();
            this.txtInjury.Properties.EndInit();
            this.txtDamage.Properties.EndInit();
            this.txtLocation.Properties.EndInit();
            this.txtAccidentName.Properties.EndInit();
            this.dtDateOccured.Properties.VistaTimeProperties.EndInit();
            this.dtDateOccured.Properties.EndInit();
            this.txtReason.Properties.EndInit();
            this.txtDescription.Properties.EndInit();
            base.ResumeLayout(false);
        }

        private void InitMultiLanguages()
        {
            this.grInformation.Text = MultiLanguages.GetString("tbl_ProcessAccidentAdd", "grInformation", this.grInformation.Text);
            this.lcAccidentName.Text = MultiLanguages.GetString("tbl_ProcessAccidentAdd", "AccidentName", this.lcAccidentName.Text);
            this.lcDateOccured.Text = MultiLanguages.GetString("tbl_ProcessAccidentAdd", "DateOccured", this.lcDateOccured.Text);
            this.lcReason.Text = MultiLanguages.GetString("tbl_ProcessAccidentAdd", "Reason", this.lcReason.Text);
            this.lcLocation.Text = MultiLanguages.GetString("tbl_ProcessAccidentAdd", "Location", this.lcLocation.Text);
            this.lcDescription.Text = MultiLanguages.GetString("tbl_ProcessAccidentAdd", "Description", this.lcDescription.Text);
            this.lcDamage.Text = MultiLanguages.GetString("tbl_ProcessAccidentAdd", "Damage", this.lcDamage.Text);
            this.lcInjury.Text = MultiLanguages.GetString("tbl_ProcessAccidentAdd", "Injury", this.lcInjury.Text);
            this.lcAllowance.Text = MultiLanguages.GetString("tbl_ProcessAccidentAdd", "Allowance", this.lcAllowance.Text);
            this.lcNote.Text = MultiLanguages.GetString("tbl_ProcessAccidentAdd", "Note", this.lcNote.Text);
        }

        private void labelControl7_Click(object sender, EventArgs e)
        {
        }

        private void LoadEmployeeInformation()
        {
            HRM_EMPLOYEE hrm_employee = new HRM_EMPLOYEE();
            hrm_employee.Get(this.m_EmployeeCode);
            this.grInformation.Text = "Th\x00f4ng Tin Tai Nạn - " + hrm_employee.EmployeeCode + " (" + hrm_employee.FirstName + " " + hrm_employee.LastName + ")";
            this.txtEmployeeName.Text = hrm_employee.FirstName + " " + hrm_employee.LastName;
        }

        private void RaiseSuccessEventHander(HRM_PROCESS_ACCIDENT item)
        {
            if (this.Success != null)
            {
                this.Success(this, item);
            }
        }

        public void SetCode(string EmployeeCode)
        {
            this.m_EmployeeCode = EmployeeCode;
            if (this.m_EmployeeCode != "")
            {
                this.glkEmployeeCode.EditValue = this.m_EmployeeCode;
                this.LoadEmployeeInformation();
            }
        }

        public void SetData(HRM_PROCESS_ACCIDENT item)
        {
            this.m_AccidentID = item.AccidentID;
            SYS_LOG.Insert("Tai Nạn Lao Động", "Xem", this.m_AccidentID.ToString());
            this.m_EmployeeCode = item.EmployeeCode;
            this.glkEmployeeCode.EditValue = this.m_EmployeeCode;
            this.glkEmployeeCode.Enabled = false;
            this.txtAccidentName.Text = item.AccidentName;
            this.txtReason.Text = item.Reason;
            this.dtDateOccured.DateTime = item.DateOccured;
            this.txtLocation.Text = item.Location;
            this.txtDescription.Text = item.Description;
            this.txtDamage.Text = item.Damage;
            this.txtInjury.Text = item.Injury;
            this.txtAllowance.Text = item.Allowance;
            this.txtNote.Text = item.Note;
            this.LoadEmployeeInformation();
        }

        protected override string uc_Change()
        {
            return string.Empty;
        }

        protected override string uc_Delete()
        {
            HRM_PROCESS_ACCIDENT item = new HRM_PROCESS_ACCIDENT {
                AccidentID = this.m_AccidentID
            };
            string str = item.Delete();
            if (str == "OK")
            {
                this.RaiseSuccessEventHander(item);
            }
            return str;
        }

        protected override string uc_Save()
        {
            if (MyRule.Get(MyLogin.RoleId, "bbiProcessAccident") != "OK")
            {
                return "";
            }
            if (!MyRule.AllowAdd)
            {
                MyRule.Notify();
                return "";
            }
            if (this.m_EmployeeCode == "")
            {
                XtraMessageBox.Show("Vui l\x00f2ng chọn nh\x00e2n vi\x00ean để lưu dữ liệu!", "Th\x00f4ng B\x00e1o", MessageBoxButtons.OK);
                return "";
            }
            SYS_LOG.Insert("Tai Nạn Lao Động", "Th\x00eam", this.m_AccidentID.ToString());
            base.SetWaitDialogCaption("Đang lưu dữ liệu...");
            Cursor.Current = Cursors.WaitCursor;
            HRM_PROCESS_ACCIDENT item = new HRM_PROCESS_ACCIDENT {
                AccidentID = Guid.NewGuid(),
                EmployeeCode = this.m_EmployeeCode,
                AccidentName = this.txtAccidentName.Text,
                Reason = this.txtReason.Text,
                DateOccured = this.dtDateOccured.DateTime,
                Location = this.txtLocation.Text,
                Description = this.txtDescription.Text,
                Damage = this.txtDamage.Text,
                Injury = this.txtInjury.Text,
                Allowance = this.txtAllowance.Text,
                Note = this.txtNote.Text
            };
            string text = item.Insert();
            if (text == "OK")
            {
                this.RaiseSuccessEventHander(item);
            }
            Cursor.Current = Cursors.Default;
            this.DoHide();
            if (text != "OK")
            {
                XtraMessageBox.Show(text, "Cảnh B\x00e1o", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            return text;
        }

        protected override string uc_Update()
        {
            if (MyRule.Get(MyLogin.RoleId, "bbiProcessAccident") != "OK")
            {
                return "";
            }
            if (!MyRule.AllowEdit)
            {
                MyRule.Notify();
                return "";
            }
            SYS_LOG.Insert("Tai Nạn Lao Động", "Cập Nhật", this.m_AccidentID.ToString());
            base.SetWaitDialogCaption("Đang cập nhật dữ liệu...");
            HRM_PROCESS_ACCIDENT item = new HRM_PROCESS_ACCIDENT {
                AccidentID = this.m_AccidentID,
                EmployeeCode = this.m_EmployeeCode,
                AccidentName = this.txtAccidentName.Text,
                Reason = this.txtReason.Text,
                DateOccured = this.dtDateOccured.DateTime,
                Location = this.txtLocation.Text,
                Description = this.txtDescription.Text,
                Damage = this.txtDamage.Text,
                Injury = this.txtInjury.Text,
                Allowance = this.txtAllowance.Text,
                Note = this.txtNote.Text
            };
            string text = item.Update();
            if (text == "OK")
            {
                this.RaiseSuccessEventHander(item);
            }
            if (text != "OK")
            {
                XtraMessageBox.Show(text, "Cảnh B\x00e1o", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            this.DoHide();
            return text;
        }

        public delegate void SuccessEventHander(object sender, HRM_PROCESS_ACCIDENT item);
    }
}

